<?php

///////////////////
$bUseSecureURL = false;
$bIgnoreSQLerrors = false;
// Set to true when deploying code to prod
//
///////////////////
if ($bUseSecureURL){
    if (substr(phpversion(),0,1) == 5)
    {
        include_once("_includes/secureURL.php");
    }
    else
    {
        include_once("_includes/secureURL.php");
//        include_once("_includes/secureURL_php4.php");
    }

    class URL_Parser_JavaScript extends URL_Parser
    {
        var $js = "javascript:gotopage";

        function isReadable($text)
        {
            if (strtolower(substr($text,0,strlen($this->js))) == $this->js)
            {
                return true;
            }

            return false;
        }

        function Read($text)
        {
            $url = substr($text,strlen($this->js) + 2); // ("
            $url = substr($url,0,strlen($url) - 3); // ");

            $url = str_replace("\\\"","\"",$url);
            $url = str_replace("\\'","'",$url);
            $url = html_entity_decode($url);

            return $url;
        }

        function Render($url)
        {
            $url = addslashes($url);

            return $this->js . "('" . $url . "');";
        }
    }


    SecureURL::setFilterIncludeOption(true); //Encode the URL when no filter matches it
    //SecureURL::addFilter(new URL_Filter_Simple("google.com",null,true,false)); //remove google from list
    SecureURL::addParser(new URL_Parser_JavaScript());
    SecureURL::Initialize(new URL_Encoder_Base64());
}
/*
if (count($_GET))
{
    echo "<pre>";
    print_r($_GET);
    echo "</pre>";
}
*/
//////////////////



//check is there is a view parameter
if (!isset($_GET['view']) || @$_GET['view'] ==null || @$_GET['view']==""){
    $_GET['view']="Home";
}

//buffer html out for php scripts that output an image MIME type
if (isset($_GET['view'])){
    if (@$_GET['view'] == "display_image_thumb" ||
        @$_GET['view'] == "display_image_full" ||
        @$_GET['view'] == "Logout"
){
        $usebufferedcontent  = true;
        $bDoNotDisplayFurniture  = true;
    }
}

//if running a report, set the following
if (isset($_GET['type'])){
    if (@$_GET['type'] == "report"){
        $usebufferedcontent  = true;
        $bDoNotDisplayFurniture  = true;
        $_GET['view']="_reports/".$_GET['view'];
    }
}

//if running a report, set the following
if (isset($_GET['type'])){
    if (@$_GET['type'] == "setup"){
        $usebufferedcontent  = true;
        $bDoNotDisplayFurniture  = true;
        $bIgnoreSQLerrors = true;
        $_GET['view']="_setup/".$_GET['view'];

        $page_view = $_GET['view'];

        $page_view_actual = $page_view.'.php';
        include(substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1).$page_view_actual);


        exit;
    }
}

//now run the page

include_once('_includes/master_include.php');

?>